feat(grpc): log per-request [REQ] line for #92 evidence slice#105
Merged
Conversation
Evidence slice for #92. Adds a defer'd log line on every unary gRPC call (auth-success and auth-failure paths both emit) carrying transport, full method, peer address, and resolved key_id (or "none" for unauthenticated requests). Loopback peer disambiguates the in-process gateway dial from external traffic, unblocking the "is anyone hitting :10000 externally" question for #94/#95. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
f1c871e to
bbfcb9f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Evidence slice for #92. Adds a defer'd log line to the gRPC
UnaryInterceptorso every call emits:Why this shape
:10000-vs-:11000question that gates Replace deprecated grpc.DialContext / WithBlock / WithInsecure in the gateway #94/Spitball: drop gRPC, rewrite as plain net/http + huma JSON service #95.peer=127.0.0.1; external traffic reaching gRPC via nginx shows the nginx container IP. Filter loopback out of the log to find the external set.key_id(not raw token, not user) is the actionable identifier. Bounded, ACP-managed, lets the operator cross-reference owner.Scope intentionally narrow — no HTTP gateway counter, no Redis persistence, no stack choice. Probe is throwaway; the long-term analytics surface gets picked when #94/#95 close.
Test plan
go test ./...— passes; two new tests inauth_test.gocover the success and auth-failure log paths.go build -v ./...make lintmake generate(no drift)go mod tidy(no drift)Local-stack smoke (CLAUDE.md manual review gate, auth touch). Observed on local API + xenforo-db + dev-redis:
[REQ] transport=grpc method=/proto.MilpacService/GetRoster peer=127.0.0.1:62807 key_id=3... peer=127.0.0.1:62870 key_id=3(distinct port from gateway dial)... peer=127.0.0.1:62873 key_id=none+Unauthenticated... peer=127.0.0.1:62874 key_id=none+UnauthenticatedLocal stack has no nginx so all peers are
127.0.0.1; in prod the gateway dial will be loopback and external traffic will show the nginx container IP — that's the disambiguation.🤖 Generated with Claude Code